package com.cuitrip.apiservice;

import android.text.TextUtils;

import com.alibaba.fastjson.TypeReference;
import com.cuitrip.apiservice.model.ApiManager;
import com.cuitrip.business.home.recommend.model.ListResponse;
import com.cuitrip.business.login.LoginInstance;
import com.cuitrip.business.user.model.CtUserInfo;
import com.cuitrip.util.I118Util;
import com.lab.network.model.CtApiRequest;
import com.lab.network.model.CtRemoteBusiness;
import com.lab.network.model.ParseType;
import com.lab.network.proxy.ApiProxy;


public class SettingBusiness {

    public static void submitAdvice(ApiProxy apiProxy, String advice) {
        CtApiRequest ctApiRequest = new CtApiRequest();
        ctApiRequest.setApiName(ApiManager.SUBMIT_FEEDBACK);
        ctApiRequest.addParam("lang", I118Util.getLanguageTag());
        ctApiRequest.addParam("content", advice);
        if (LoginInstance.getInstance().getUserInfo() != null){
            CtUserInfo ctUserInfo = LoginInstance.getInstance().getUserInfo();
            if (!TextUtils.isEmpty(ctUserInfo.getEmail())){
                ctApiRequest.addParam("email", ctUserInfo.getEmail());
            }
            if (!TextUtils.isEmpty(ctUserInfo.getMobile())){
                ctApiRequest.addParam("mobile", ctUserInfo.getMobile());
            }
            if (!TextUtils.isEmpty(ctUserInfo.getCountryCode())){
                ctApiRequest.addParam("countryCode", ctUserInfo.getCountryCode());
            }
        }
        CtRemoteBusiness ctRemoteBusiness = new CtRemoteBusiness(ctApiRequest);
        apiProxy.postAsync(ctRemoteBusiness, new ParseType(new TypeReference<ListResponse>() {
        }.getType()));
    }
}
